<?php

/**
 * 路由测试
 */

use think\facade\Route;

$nameSpice = "\app\home\controller\\";

/** 普通路由测试 **/
Route::get('/', $nameSpice . 'Index@index');
Route::any('test123123', $nameSpice . 'Index@test');
Route::any('test1', $nameSpice . 'Index@test1');

Route::any('onlineUser', $nameSpice . 'Index@onlineUser');  //在线用户统计
Route::any('chatBingUser', $nameSpice . 'Index@chatBingUser');  //绑定用户id
Route::any('getOnlineUser', $nameSpice . 'Index@getOnlineUser');  //获取在线用户

Route::any('video/play', $nameSpice . 'Index@video');  //获取在线用户

Route::get('start', $nameSpice . 'Index@start');
Route::any('captcha', '\app\controller\Index@captcha');

Route::get('search', $nameSpice . 'Search@index');


/** 上传测试 **/
Route::get('upload', $nameSpice . 'Upload@show');
Route::post('/upload/getToken', $nameSpice . 'Upload@getToken');

/** 聊天测试 **/
Route::get("chatroom/[:id]", $nameSpice . 'Chat@index');

Route::group('chat', function () use ($nameSpice) {
    Route::post('/addRoom', $nameSpice . 'Chat@addRoom');
    Route::post('/addSpeak', $nameSpice . 'Chat@addSpeak');
    Route::post('/bingUser', $nameSpice . 'Chat@bingUser');
    Route::post('/onlineList', $nameSpice . 'Chat@getOnlineList');
    Route::post('/disconnect', $nameSpice . 'Chat@disconnect');
});

///** 中间件测试 **/
//Route::group(function () use ($nameSpice) {
//    Route::get('yq/test', $nameSpice . 'yq\Yq@index');
//})->middleware(YqCheck::class);


/** 域名路由测试 **/
Route::domain('blog', function () {
    // 动态注册域名的路由规则
    Route::rule('/', '\app\controller\blog\Index@index');
//    Route::rule(':user', 'user/info');
});
//})->bind('blog');


/** 未定义路由测试 **/
Route::miss(function () {
    return view('404');
});

/** 跨域路由测试 **/
Route::get('login', $nameSpice . 'Login/check')
    ->ext('html')
    ->allowCrossDomain([
        'Access-Control-Allow-Origin' => 'thinkphp.cn',  //限制访问的域名
        'Access-Control-Allow-Credentials' => 'true'
    ]);
//    ->middleware(\app\middleware\LoginCheck::class);